home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
a_utils
/
expanded.lha
/
expanded
/
src
/
Object.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-03-19
|
8KB
|
281 lines
//
// Linear-Affine-Projective Geometry Package
//
// Object.C
//
// $Header$
//
// William J.R. Longabaugh
// University of Washington
//
// Implementation of the linear-affine-projective geometry
// package described in William J.R. Longabaugh, "An Expanded
// System for Coordinate-Free Geometric Programming", Master's
// thesis, University of Washington, 1992.
//
// Copyright (c) 1992, William J.R. Longabaugh
// Copying, use and development for non-commercial purposes permitted.
// All rights for commercial use reserved.
// This software is unsupported and without warranty; it is
// provided "as is".
//
// ***********************************************************************
#include <string.h>
#include "Object.h"
const char *ast =
"**************************************************************\n";
//
// Create a global error handler:
//
ErrorHandler errh;
// ***********************************************************************
// ***********************************************************************
//
// ErrorHandler class
//
// ***********************************************************************
// ***********************************************************************
//
// Currently, there is nothing to do when constructing an Error Handler:
//
ErrorHandler::ErrorHandler(void) {}
// ***********************************************************************
//
// Create a whole bunch of error exit calls. Each takes a different
// number of objects to print out. Not very elegant, but type-safe:
//
void ErrorHandler::ErrorExit(char *errloc, char *descript)
{
cout << ast << "FATAL PROGRAM ERROR\n";
cout << "Error occurred in: " << errloc << "\n";
cout << "Error description: " << descript << "\n";
cout << ast;
abort();
}
void ErrorHandler::ErrorExit(char *errloc, char *descript, Object &o1)
{
cout << ast << "FATAL PROGRAM ERROR\n";
cout << "Error occurred in: " << errloc << "\n";
cout << "Error description: " << descript << "\n";
cout << "Contents of Relevant Objects:\n";
o1.debug_out(cout, ERR_IND);
cout << ast;
abort();
}
void ErrorHandler::ErrorExit(char *errloc, char *descript, Object &o1,
Object &o2)
{
cout << ast << "FATAL PROGRAM ERROR\n";
cout << "Error occurred in: " << errloc << "\n";
cout << "Error description: " << descript << "\n";
cout << "Contents of Relevant Objects:\n";
o1.debug_out(cout, ERR_IND);
o2.debug_out(cout, ERR_IND);
cout << ast;
abort();
}
void ErrorHandler::ErrorExit(char *errloc, char *descript, Object &o1,
Object &o2, Object &o3)
{
cout << ast << "FATAL PROGRAM ERROR\n";
cout << "Error occurred in: " << errloc << "\n";
cout << "Error description: " << descript << "\n";
cout << "Contents of Relevant Objects:\n";
o1.debug_out(cout, ERR_IND);
o2.debug_out(cout, ERR_IND);
o3.debug_out(cout, ERR_IND);
cout << ast;
abort();
}
void ErrorHandler::ErrorExit(char *errloc, char *descript,
Object &o1, Object &o2, Object &o3, Object &o4)
{
cout << ast << "FATAL PROGRAM ERROR\n";
cout << "Error occurred in: " << errloc << "\n";
cout << "Error description: " << descript << "\n";
cout << "Contents of Relevant Objects:\n";
o1.debug_out(cout, ERR_IND);
o2.debug_out(cout, ERR_IND);
o3.debug_out(cout, ERR_IND);
o4.debug_out(cout, ERR_IND);
cout << ast;
abort();
}
void ErrorHandler::ErrorExit(char *errloc, char *descript, Object &o1,
Object &o2, Object &o3, Object &o4, Object &o5)
{
cout << ast << "FATAL PROGRAM ERROR\n";
cout << "Error occurred in: " << errloc << "\n";
cout << "Error description: " << descript << "\n";
cout << "Contents of Relevant Objects:\n";
o1.debug_out(cout, ERR_IND);
o2.debug_out(cout, ERR_IND);
o3.debug_out(cout, ERR_IND);
o4.debug_out(cout, ERR_IND);
o5.debug_out(cout, ERR_IND);
cout << ast;
abort();
}
// ***********************************************************************
// ***********************************************************************
//
// Object class
//
// ***********************************************************************
// ***********************************************************************
//
// Stream output function for the object class.
//
ostream& operator<<(ostream &c, Object &o)
{
o.debug_out(c, 0);
return (c);
}
// ***********************************************************************
// ***********************************************************************
//
// ErrVal class
//
// ***********************************************************************
// ***********************************************************************
//
// This class lets us print out important numeric values associated
// with error conditions.
//
// ***********************************************************************
ErrVal::ErrVal(char *message, int val)
{
text = new char[strlen(message) + 1];
strcpy(text, message);
isint = TRUE;
value = (Scalar)val;
}
// ***********************************************************************
ErrVal::ErrVal(char *message, Scalar val)
{
text = new char[strlen(message) + 1];
strcpy(text, message);
isint = FALSE;
value = val;
}
// ***********************************************************************
ErrVal::~ErrVal(void)
{
delete text;
}
// ***********************************************************************
// To do debug printing:
void ErrVal::debug_out(ostream &c, int indent)
{
char *ibloc = new char[indent + 1];
for (int i = 0; i < indent; i++) {
*(ibloc + i) = ' ';
}
*(ibloc + indent) = '\0';
c << ibloc << ast;
c << ibloc << text << ((isint) ? (int)value : value) << "\n";
c << ibloc << ast;
delete ibloc;
return;
}
// ***********************************************************************
// ***********************************************************************
//
// ErrType class
//
// ***********************************************************************
// ***********************************************************************
//
// This class lets us print out enumerated types associated
// with error conditions.
//
// ***********************************************************************
ErrType::ErrType(char *message, int val, EnumSet s)
{
text = new char[strlen(message) + 1];
strcpy(text, message);
value = val;
set = s;
}
// ***********************************************************************
ErrType::~ErrType(void)
{
delete text;
}
// ***********************************************************************
// To do debug printing:
void ErrType::debug_out(ostream &c, int indent)
{
char *ibloc = new char[indent + 1];
for (int i = 0; i < indent; i++) {
*(ibloc + i) = ' ';
}
*(ibloc + indent) = '\0';
c << ibloc << ast;
c << ibloc << text << " ";
switch (set) {
case SPACETYPES:
SpaceTypeOut(c, (SpaceType)value);
break;
case BASISTYPES:
BasisTypeOut(c, (BasisType)value);
break;
case GEOBTYPES:
GeObTypeOut(c, (GeObType)value);
break;
case MAPTYPES:
MapTypeOut(c, (MapType)value);
break;
case MULTITYPES:
MultiTypeOut(c, (MultiType)value);
break;
case SUBSETTYPES:
SubSetTypeOut(c, (SubSetType)value);
break;
case SRELTYPES:
SRelOut(c, (SRel)value);
break;
}
c << "\n";
c << ibloc << ast;
delete ibloc;
return;
}
// ***********************************************************************